layui.config({
    base: '../layui/sliderVerify/'
}).use(['sliderVerify'], function() {
    var sliderVerify = layui.sliderVerify;
    var form = layui.form;
    var slider = sliderVerify.render({
        elem: '#slider',
        onOk: function(){//当验证通过回调
            layer.msg("滑块验证通过");
        }
    });
    //监听提交
    form.on('submit(submitLogin)', function(data) {
        if(slider.isOk()){//用于表单验证是否已经滑动成功
            layer.msg(JSON.stringify(data.field));
        }else{
            layer.msg("请先通过滑块验证");
        }
        return false;
    });
})